<template>
    <div>
        <h1>我是首页哈哈哈</h1>
        <h4>{{home}}</h4>
        <router-link to="/Home/News">新闻</router-link>
        <router-link to="/Home/Msg">消息</router-link>
        <router-view></router-view>
    </div>
</template>

<script>
    export default {
        name: "Home",
        data(){
          return{
              path:'/Home/News'
          }
        },
        computed: {
            home() {
                return this.$route.params.home
            }
        },
        created() {
            console.log("Home被创建");
        },
        destroyed() {
            console.log("Home被销毁");
        },
        // activated 和 deactivated只有在 该组件被keep-alive保存状态的时候才会生效
        activated() {
            this.$router.push(this.path)
            console.log("home activated");
        },
        deactivated() {
            console.log("home deactivated");
        },
        beforeRouteLeave(to,from,next){
            this.path = this.$route.path
            next()
        }

    }
</script>

<style scoped>

</style>
